'use strict'

function note (args) {
  var theme = hexo.theme.config
  var icon = theme.icon && theme.icon.notetag_default
  var iconType = 'default'
  let Tip;
  
  let langNames = {
      cn: "简体中文",
      tw: "繁体中文",
      en: "English"
  }
  
  switch (args[0]) {
      case 'cn':
          Tip = `提示
该文章同时提供：`;
          break;
      case 'en':
          Tip = `Note
The article is also available at: `;
          break;
      case 'tw':
          Tip = `提示
該文章同時提供：`;
          break;
      default:
          Tip = `提示
该文章同时提供：`;
  }
  let contentList = args[1].split(",");
  for(let i=0;i<contentList.length;++i){
      let item = contentList[i].split("=");
      item[0] = item[0].trim();
      item[1] = item[1].trim();
      Tip += `[${langNames[item[0]]}](/${item[0]}/article/${item[1]})，`;
  }
  Tip = Tip.substr(0,Tip.length-1);
  
  return `
    <div class="note-plugin info">
      <span class="note-plugin__icon note-plugin__icon--info">
        <i class="fas fa-info-circle"></i>
      </span>
      ${hexo.render
        .renderSync({ text: Tip, engine: 'markdown' })
        .split('\n')
        .join('')}
    </div>
  `
}

hexo.extend.tag.register('lang', note, { ends: false })
